package 
{
	import anshe.event.AnsheClientEvent;
	import anshe.event.AnsheNetEvent;
	import anshe.event.TitleEvent;
	import anshe.object.TitleObject;
	import anshe.widget.AnsheClient;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.utils.Timer;
	
	import imvu.rbox.RBoxData;
	import imvu.rbox.event.ActionEvent;
	import imvu.rbox.event.MsgEvent;
	import imvu.rbox.global.GStatic;
	import imvu.rbox.object.MainGameObject;
	import imvu.rbox.object.RoomSelect;
	import imvu.rbox.struct.CGamePlayerInfo;
	import imvu.rbox.struct.CGameRoomInfo;
	
	import org.dstart.csuper.SuperSprite;

	public class RussianBox extends AnsheClient
	{
		public var mcTitle:TitleObject;			//	菜单标题对象
		public var mcRoomSelect:RoomSelect;		//	房间选择对象
		public var mcGameMain:MainGameObject;	//	主游戏框架
		
		public var txtRoomList:TextField;		//	显示房间列表
		public var txtUserList:TextField;		//	显示用户列表
		
		private var sprMain:SuperSprite;		//	影片放置处
		
		public function RussianBox()
		{
			super("RussianBox", "Tetris", new RBoxData());
		}
		
		//	初始化游戏时调用		
		public override function InitGameListener():void
		{			
			AddListener(MsgEvent.S_CREATE_ROOM_DONE, CreateRoomDone);	//	注册创建房间完毕事件
		}		

		//-----------------------------------------------------------
		
		private function InitObject():void
		{
			//**
			sprMain = new SuperSprite();
			
			this.addChild(sprMain);	
			this.addChild(mcTitle);
			
			sprMain._root.addChild(mcGameMain);
			sprMain._root.addChild(mcRoomSelect);
			
			//**
			this.txtRoomList.visible = false;
			this.txtUserList.visible = false;
			// mcRoomSelect.visible = false;
			//**/	
		}
		
		private function InitListener():void
		{
			//	设置标题对象事件侦听
			this.mcTitle.addEventListener(TitleEvent.MIN_WINDOW, onWinMinClick);
			this.mcTitle.addEventListener(TitleEvent.RETURN_WINDOW, onWinReturnClick);
			this.mcTitle.addEventListener(TitleEvent.CLOSE_WINDOW, onWinCloseClick);	
			this.mcTitle.addEventListener(TitleEvent.SHOW_HELP, onShowHelpClick);
			
			this.mcTitle.addEventListener(TitleEvent.START_DRAG, onStageStartDrag);
			this.mcTitle.addEventListener(TitleEvent.STOP_DRAG, onStageStopDrag);
			
			//	房间内事件侦听
			this.mcRoomSelect.addEventListener(ActionEvent.CREATE_NEW_ROOM, onCreateNewRoomEvent);
			this.mcRoomSelect.addEventListener(ActionEvent.JOIN_ROOM, onJoinRoomEvent);
			
			//	游戏房间内事件侦听
			this.mcGameMain.addEventListener(ActionEvent.IS_READY, onUserReadyGame);
			this.mcGameMain.addEventListener(ActionEvent.QUIT_ROOM, onUserQuitRoom);
			this.mcGameMain.addEventListener(ActionEvent.BOX_DONE, onBoxDoneEvent);
			this.mcGameMain.addEventListener(ActionEvent.GAME_DONE, onGameDoneEvent);
			this.mcGameMain.addEventListener(ActionEvent.UPDATA_LINE, onBoxDoneEvent);
			this.mcGameMain.addEventListener(ActionEvent.TICK_USER, onTickUserEvent);
			this.mcGameMain.addEventListener(ActionEvent.CLOSE_SEAT, onCloseSeatEvent);
			this.mcGameMain.addEventListener(TitleEvent.START_DRAG, onStageStartDrag);
			this.mcGameMain.addEventListener(TitleEvent.STOP_DRAG, onStageStopDrag);
			
			this.mcGameMain.addEventListener(TitleEvent.START_DRAG, onStageStartDrag);
			this.mcGameMain.addEventListener(TitleEvent.STOP_DRAG, onStageStopDrag);
			
			//	来自于基类的事件侦听
			this.addEventListener(AnsheClientEvent.UPDATA_ROOM_INFO, onRushRoomInfo);
			this.addEventListener(AnsheClientEvent.UPDATA_PLAYER_INFO, onRushPlayerInfo);	
			this.addEventListener(AnsheClientEvent.JOIN_GAME_DONE, onJoinGameDone);		
			
			//	全局事件侦听
			// if(this.space)
			//{
			this.stage.addEventListener(AnsheNetEvent.SERVER_CLOSE, onServerCloseEvent);
			//}
			
			//rTime = new Timer(500);
			//rTime.addEventListener(TimerEvent.TIMER, onShowText);
			//rTime.start();
			// this.addEventListener(Event.ENTER_FRAME, onShowText);		
		}
		
		private function onServerCloseEvent(e:AnsheNetEvent):void
		{
			GStatic.ShowMessage(this, "Server Closed!");
			if(GStatic.isGameStart)
			{
				GStatic.Trace("与服务器断开连接");
				GameOver(0, 0);
			}
		}
		
		private var rTime:Timer;
		
		private function onShowText(e:Event):void
		{
			this.txtRoomList.text = "allRoom:" + this.roomArray.length + "\n";
			try
			{				
				for(var i:int = 0; i < this.roomArray.length; i++)
				{
					var rInfo:CGameRoomInfo = this.roomArray[i];
					var rStr:String = 	"roomID: " + rInfo.roomID + 
										" now: " + rInfo.nowPlayer + 
										" max: " + rInfo.maxPlayer + 
										" isPlaying: " + rInfo.isPlaying + "\n" 
					this.txtRoomList.appendText(rStr); 				
				}				
			}
			catch(err:*)
			{
				ShowMessage("显示房间信息时出错" + err);
			}
			
			this.txtUserList.text = "allUser:" + this.userArray.length + "\n";
			try
			{				
				for(var j:int = 0; j < this.userArray.length; j++)
				{
					var uInfo:CGamePlayerInfo = this.userArray[j];
					if(uInfo)
					{
						var str:String = "uName : " + uInfo.userName +
										" uID : " + uInfo.userID +
										" roomID : " + uInfo.roomID +
										" seatID : " + uInfo.seatID +
										" isReady : " + uInfo.isReady +
										" score : " + uInfo.userScore +
										" nowPower : " + uInfo.nowPower;
						this.txtUserList.appendText(str + "\n");
					} 				
				}				
			}
			catch(err:*)
			{
				ShowMessage("显示用户信息时出错" + err);
			}

		}
		
		private function onUserReadyGame(e:ActionEvent):void
		{
			// GStatic.ShowMessage(this, "Can't start game !");
			SendCommand(MsgEvent.C_READY_GAME, "onReadyGame");//, GStatic.myInfo.userID);
		}
		
		//	当服务器认为不允许继续准备时触发
		public function onReadyGame(argc:Array):void
		{	
			if(GStatic.isRoomMaster)
			{
				if(!Boolean(argc[0]))
				{		
					GStatic.ShowMessage(this, "Can't start game !\nPlease wait all player ready.");
				}
			}
			// ShowMessage("onReadyGame::" + argc);
		}
				 
		private function onUserQuitRoom(e:ActionEvent):void
		{
			SendCommand(MsgEvent.C_QUIT_ROOM, "onQuitRoom");//, GStatic.myInfo.userID);
		}
		
		private var sendID:Number = 0;
		
		private function onBoxDoneEvent(e:ActionEvent):void
		{
			var obj:Object = e.data;
			
			GStatic.myInfo.cleanLines += obj.lines;
			
			if(GStatic.nowRoom.gameData.length <= 190)
			{
				SendCommand(MsgEvent.C_RUSH_GAMD_LIST, "onGetGameData");
			}
			
			// ShowMessage("为发送数据进行更新游戏数据");// + obj.lines + " : " + obj.data);
			if(obj.lines > 0)
			{
				sendID = 0;
			}
			else
			{
				sendID ++;
				if(sendID > 3)
				{
					sendID = 0;
				}			
			}
			
			if(sendID == 0)
			{
				// trace("rushbox:", GStatic.myInfo.clientID);
				UpdataPlayerInfo(GStatic.myInfo.clientID, obj.lines, obj.data);//.join(","));
			}
		}
		
		private function onGameDoneEvent(e:ActionEvent):void
		{
			var obj:Object = e.data;
			
			// ShowMessage("为发送数据进行更新游戏数据" + obj.lines + " : " + obj.data);
			// trace("rushboxbyGameDone:", GStatic.myInfo.clientID);
			UpdataPlayerInfo(GStatic.myInfo.clientID, obj.lines, obj.data);
			
			SendCommand(MsgEvent.C_USER_GAME_OVER, "onUserGameOver");
		}				
		
		public function onGetGameData(argc:Array):void
		{
			// ShowMessage("收到房间数据" + argc);
		}
		
		public function onQuitRoom(argc:Array):void
		{
			// ShowMessage("onQuitRoom::" + argc);
		}
		
		public function onUserGameOver(argc:Array):void
		{
			// ShowMessage("onUserGameOver!" + argc);
		}
		
		
		private function onTickUserEvent(e:ActionEvent):void
		{
			SendCommand(MsgEvent.C_TICK_USER, "onTickUser", e.data.userID);
		}
		
		public function onTickUser(array:Array):void
		{
			// ShowMessage("收到踢除玩家的事件:" + array);
		}
		
		private function onCloseSeatEvent(e:ActionEvent):void
		{
			SendCommand(MsgEvent.C_CLOSE_SEAT, "onCloseSeat", e.data.seatID);
		}
		
		public function onCloseSeat(array:Array):void
		{
			// ShowMessage("收到关闭坐位的事件:" + array);
		}
		
		//	刷新房间列表
		private function onRushRoomInfo(e:AnsheClientEvent):void
		{
			try
			{
				if(GStatic.nowRoom)
				{
					if(e.data)
					{
						var rInfo:CGameRoomInfo = e.data as CGameRoomInfo;
						// trace("getRoomInfo::", rInfo);
						// trace("nowRoomInfo::", GStatic.nowRoom);
						
						if(rInfo.roomID == GStatic.nowRoom.roomID)
						{
							GStatic.nowRoom.gameModel = rInfo.gameModel;
							GStatic.nowRoom.gameSpeed = rInfo.gameSpeed;
							GStatic.nowRoom.isPlaying = rInfo.isPlaying;
							GStatic.nowRoom.maxTime = rInfo.maxTime;
							GStatic.nowRoom.maxPlayer = rInfo.maxPlayer;
							GStatic.nowRoom.seatArray = rInfo.seatArray.slice();						
						}
					}
				}
			}
			catch(err:*)
			{
				trace("更新房间信息时发生错误：" + err);
			}
			this.mcRoomSelect.RushRoom(this.roomArray);
		}
		
		//	刷新房间内用户列表
		private function onRushPlayerInfo(e:AnsheClientEvent):void
		{
			//	更新用户信息列表
			try
			{
				// ShowMessage("当前用户列表:" + this.userArray.length);
			
				this.mcGameMain.RushUserInfo(e.data as CGamePlayerInfo);
			}
			catch(err:*)
			{
				trace("发生错误:" + err);
			}
			// this.mcGameMain.RushUsers(this.userArray);
		}
		
		private function onJoinGameDone(e:AnsheClientEvent):void
		{
			var argc:Array = e.data as Array;
			
			GStatic.myInfo.clientID = argc[2];
		}
		
		private function onCreateNewRoomEvent(e:ActionEvent):void
		{
			var gInfo:CGameRoomInfo = e.data as CGameRoomInfo;
			
			trace("发送创建房间事件");
			SendCommand(MsgEvent.C_CREATE_NEW_ROOM, "onCreateError", gInfo.boxNumber, gInfo.gameSpeed, gInfo.gameModel, gInfo.maxTime);
		}		
		
		public function onCreateError(argc:Array):void
		{
			// ShowMessage("onCreateError..." + argc);
		}
		
		private function onJoinRoomEvent(e:ActionEvent):void
		{
			var gInfo:CGameRoomInfo = e.data as CGameRoomInfo;
			
			GStatic.myInfo.roomID = gInfo.roomID;
			GStatic.nowRoom = gInfo;
			
			SendCommand(MsgEvent.C_JOIN_ROOM, "onJoinRoomDone", gInfo.roomID);
		}
		
		//	加入游戏房间成功
		public function onJoinRoomDone(argc:Array):void
		{
			// ShowMessage("onJoinRoomDone..." + argc);

			var isJoinDone:Boolean = Boolean(argc[0]);
			var uArray:Array = argc[1];
			
			// traceObject(uArray);
			
			//**
			if(isJoinDone)
			{
				this.mcRoomSelect.enabled = true;
				this.mcRoomSelect.visible = false;
				this.mcGameMain.JoinGame(false);
				
				GStatic.isRoomMaster = false;
				
				this.ShowMessage("重组用户结构");
				this.userArray = new Array();
				
				for(var i:int = 0; i < argc[1].length; i++)
				{
					AddPlayerInfo(argc[1][i]);
				}

				CreateRoomSO(GStatic.nowRoom.soName);
				
				this.mcGameMain.JoinGame(GStatic.isRoomMaster);		
				this.mcGameMain.RushUsers(userArray);
			}
			else
			{
				this.mcRoomSelect.enabled = true;
				GStatic.ShowMessage(this, "Can't join the game!");
			}		 
		}
		
		/** 点击 最小化 按钮后功能 **/
		private function onWinMinClick(e:Event):void
		{
			this.mcTitle.btnMin.visible = false;
			this.mcTitle.btnReturn.visible = true;
			
			this.sprMain.visible = false;
		}

		/** 点击 还原窗口 按钮后功能 **/
		private function onWinReturnClick(e:Event):void
		{
			this.sprMain.visible = true;
		}

		/** 点击 帮助 按钮后触发事件 */
		private function onShowHelpClick(e:Event):void
		{
			// flash.net.navigateToURL(new URLRequest("http://system.anshechung.com/help/magicpainter"), "_blank");
		}	

		/** 点击 关闭 按钮 后功能  （上级对象删除自己） **/
		private function onWinCloseClick(e:Event):void
		{
			// ShowMessage("准备删除对象：" + this);
			
			mcGameMain.RushGameBase(false);
			
			onUserQuitRoom(null);
			
			SendCommand(MsgEvent.C_QUIT_GAME, "");
			
			RemoveThisGame();
			// DeleteSWF();
		}
		
		/** 开始拖动整体对象（整个 MC 本身） **/
		private function onStageStartDrag(e:*):void
		{
			// this.sprMain.OpenBitmap(550, 400);	
			
			this.startDrag();
			
			this.stage.addEventListener(MouseEvent.MOUSE_UP, onStageStopDrag);
		}
		
		/** 停止拖动对象（整个 MC 本身）**/
		private function onStageStopDrag(e:*):void
		{
			// this.sprMain.CloseBitmap();
			
			this.stopDrag();

			this.stage.removeEventListener(MouseEvent.MOUSE_UP, onStageStopDrag);
		}
		
		//----------------------------------------------------------------------
		//	以下为服务器端需要调用的消息
		//----------------------------------------------------------------------
		
		//	（服务器调用）创建房间完毕后,由服务器自动调用的方法
		public function CreateRoomDone(...argc):void
		{
			// ShowMessage("创建了一个新房间 Room :: " + argc);
			//	如果返回创建房间成功的标识为 true ,则代表创建房间成功, 此时自动进入到房间内部.
			if(Boolean(argc[1]))
			{
				this.mcRoomSelect.visible = false;
				GStatic.isRoomMaster = true;
				
				this.mcGameMain.JoinGame(GStatic.isRoomMaster);		

				//	取到自己所在房间的 ID 号，同时让自己坐到 1 号位置上
				GStatic.myInfo.roomID = Number(argc[2]);
				GStatic.myInfo.seatID = 1;
				
				// ShowMessage("重组用户数据");
				
				this.userArray = new Array();
				this.userArray.push(GStatic.myInfo);
				
				this.mcGameMain.RushUsers(this.userArray);
				
				this.addEventListener(Event.ENTER_FRAME, CheckNowRoom);
			}			
		}
		
		//	检测自己的房间数据
		private function CheckNowRoom(e:Event):void
		{
			var myRoom:CGameRoomInfo = GetRoomByID(GStatic.myInfo.roomID) as CGameRoomInfo;
			if(myRoom)
			{
				// ShowMessage("找到当前的房间，其信息是： " + myRoom);
				
				GStatic.nowRoom = myRoom;
				GStatic.myInfo.roomID = myRoom.roomID;
				
				CreateRoomSO(GStatic.nowRoom.soName);
				
				this.removeEventListener(Event.ENTER_FRAME, CheckNowRoom);
			}
		}
		
		//	（服务器调用）有玩家退出房间时由服务器调用方法
		public function UserQuit(...argc):void
		{
			// ShowMessage("有玩家退出了房间 :: " + argc);
			
			try
			{
				if(GStatic.myInfo.userID.indexOf(argc[1]) >= 0)
				{
					//	如果自己离开房间
					GStatic.nowRoom = new CGameRoomInfo();
					GStatic.myInfo.roomID = 0;
					GStatic.isGameStart = false;
					GStatic.isShowInfo = false;
					
					this.userArray = new Array();				
										
					this.roomSO.close();
					this.mcRoomSelect.visible = true;
					this.mcGameMain.StopTime();
					this.mcGameMain.RushUsers(userArray);
				}
				this.mcGameMain.DoUserQuit(argc[1]);
				DeleteUser(argc[1]);
			}
			catch(err:*)
			{
				trace("删除玩家时发生错误");
			}
		}	
		
		private function DeleteUser(uID:String):void
		{
			var tArray:Array = new Array();
			
			for(var i:int = 0; i < this.userArray.length; i++)
			{
				var pInfo:CGamePlayerInfo = this.userArray[i];
				if(pInfo.userID.indexOf(uID) < 0)
				{
					tArray.push(pInfo);
				}
			}
			
			this.userArray = tArray;
		}	
		
		//	（服务器调用）向游戏中追加游戏数据时调用的方法
		public function AppendGameData(...argc):void
		{
			// ShowMessage("追加新的数据到房间方块列表 :: " + argc);
			GStatic.nowRoom.gameData = GStatic.nowRoom.gameData.concat(argc[1]);
		}

		//	（服务器调用）向游戏中追加游戏数据时调用的方法
		public function UserGameOver(...argc):void
		{
			// ShowMessage("有用户已经游戏结束 :: " + argc);
			this.mcGameMain.ShowGameOver(argc[1]);
			(GetPlayerByID(argc[1]) as CGamePlayerInfo).isDead = true;
		}

		//	（服务器调用）向游戏中追加游戏数据时调用的方法
		public function GameOver(...argc):void
		{
			// ShowMessage("游戏结束 :: " + argc);

			this.mcGameMain.ShowScore(userArray, Number(argc[1]));
			
			for(var i:int = 0; i < this.userArray.length; i++)
			{
				var uInfo:CGamePlayerInfo = this.userArray[i] as CGamePlayerInfo;
				uInfo.isReady = false;
				uInfo.userScore = 0;
				uInfo.isPower = false;	
				uInfo.isDead = false;			
			}

			this.mcGameMain.RushGameBase();
		}

		//	有用户已经 GameOver　，同时点击了继续游戏按钮
		public function GameCountinue(...argc):void
		{
			// ShowMessage("游戏中继续游戏：" + argc);
		}
		
		//	（服务器调用）变更房主时触发
		public function ChangeRoomMaster(...argc):void
		{
			// ShowMessage("房间内房主发生变更：" + argc);
			if(GStatic.myInfo.userID.indexOf(argc[1]) >= 0)
			{
				GStatic.isRoomMaster = true;
				this.mcGameMain.JoinGame(true);
			}
			else
			{
				this.mcGameMain.ChangeFlag(argc[1]);
			}
		}
		
		//	删除一个房间
		public function CloseRoom(...argc):void
		{
			//this.ShowMessage("收到关闭房间消息::" + argc);
			//this.ShowMessage("当前有房间::" + this.roomArray.length);
			
			for(var i:int = 0; i < this.roomArray.length; i++)
			{
				var rInfo:CGameRoomInfo = this.roomArray[i];
				if(rInfo.roomID == Number(argc[1]))
				{
					this.roomArray.splice(i, 1);
					break;
				}
			}
			// this.ShowMessage("删除后剩余房间:" + this.roomArray.length);
			this.mcRoomSelect.RushRoom(this.roomArray);
		}
		
		//	（服务器调用）游戏开始
		public function GameStart(...argc):void
		{
			// trace("游戏开始" + argc.length);
			GStatic.nowRoom.gameData = GStatic.nowRoom.gameData.concat(argc[1]);
			// GStatic.nowRoom.gameData = new Array(2,3,4,10,11,12,13,14,15,16,17,18);
						
			this.mcGameMain.StartGame();
		}
		
		//	（服务器调用）更新游戏加行的数据
		public function UpdataPower(...argc):void
		{
			// ShowMessage("取得 爆气后更新游戏数据 的消息::" + argc);
			
			//if(GStatic.myInfo.userID.indexOf(argc[1]) < 0)
			//{
			this.mcGameMain.UpdataGameData(argc[1], argc[2]);
			//}
		}
				
		//----------------------------------------------------------------------
		//	以下为初始化相关信息时调用方法
		//----------------------------------------------------------------------

		private function InitBaseData():void
		{
			// trace("找到的 space 是:" + this.space);
			if(this.space)
			{
				if(this.space.myInfo)
				{
					GStatic.myInfo = new CGamePlayerInfo();
					GStatic.myInfo.name = this.space.myInfo.userName;
					GStatic.myInfo.userID = this.space.myInfo.userID;
					GStatic.myInfo.imvuID = this.space.myInfo.imvuID;
					GStatic.myInfo.userFace = this.space.myInfo.userFace;
					GStatic.myInfo.isGirl = this.space.myInfo.isGirl;
					
					ShowMessage("查到当前用户的相关信息:: " + GStatic.myInfo);
				}
				else
				{
					ShowMessage("找不到用户信息");
				}
				
				if(this.space.fDebug)
				{
					GStatic.fDebug = this.space.fDebug;
				}				
			}
			else
			{
				ShowMessage("找不到 space 对象：：" + this.space);
			}
		}				
		
		//-----------------------------------------------------
		//	以下为重写基类中已经定义好的方法
		//----------------------------------------------------------------------
		
		//	程序初始化时调用方法
		protected override function InitGame():void
		{
			super.InitGame();
			
			// ShowMessage("俄罗斯方块游戏初始化一次");

			InitBaseData();
			InitObject();
			InitListener();
			
			JoinGame();
			GStatic.Trace("<<<<<< LoginOK >>>>>>");
			this.stage.frameRate = 20;
		}
		
		protected override function DeleteListener():void
		{
			if(this.roomSO)
			{
				this.roomSO.close();
			}
			if(this.gameSO)
			{
				this.gameSO.close();
			}
			
			trace("删除方块游戏的相关侦听");
			
			this.mcGameMain.DeleteListener();
			this.mcRoomSelect.DeleteListener();
			
			//	设置标题对象事件侦听
			this.mcTitle.removeEventListener(TitleEvent.MIN_WINDOW, onWinMinClick);
			this.mcTitle.removeEventListener(TitleEvent.RETURN_WINDOW, onWinReturnClick);
			this.mcTitle.removeEventListener(TitleEvent.CLOSE_WINDOW, onWinCloseClick);	
			this.mcTitle.removeEventListener(TitleEvent.SHOW_HELP, onShowHelpClick);
			
			this.mcTitle.removeEventListener(TitleEvent.START_DRAG, onStageStartDrag);
			this.mcTitle.removeEventListener(TitleEvent.STOP_DRAG, onStageStopDrag);
			
			//	房间内事件侦听
			this.mcRoomSelect.removeEventListener(ActionEvent.CREATE_NEW_ROOM, onCreateNewRoomEvent);
			this.mcRoomSelect.removeEventListener(ActionEvent.JOIN_ROOM, onJoinRoomEvent);
			
			//	游戏房间内事件侦听
			this.mcGameMain.removeEventListener(ActionEvent.IS_READY, onUserReadyGame);
			this.mcGameMain.removeEventListener(ActionEvent.QUIT_ROOM, onUserQuitRoom);
			this.mcGameMain.removeEventListener(ActionEvent.BOX_DONE, onBoxDoneEvent);
			this.mcGameMain.removeEventListener(ActionEvent.GAME_DONE, onGameDoneEvent);
			this.mcGameMain.removeEventListener(ActionEvent.TICK_USER, onTickUserEvent);
			this.mcGameMain.removeEventListener(ActionEvent.CLOSE_SEAT, onCloseSeatEvent);
			
			//	来自于基类的事件侦听
			this.removeEventListener(AnsheClientEvent.UPDATA_ROOM_INFO, onRushRoomInfo);
			this.removeEventListener(AnsheClientEvent.UPDATA_PLAYER_INFO, onRushPlayerInfo);
			
			// rTime.stop();			
			// rTime.removeEventListener(TimerEvent.TIMER, onShowText);
		}
	}
}
